<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>意见反馈列表</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/themes/bootstrap/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/demo/demo.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
</head>
<body>
	<table id="feedbackDg" title="意见反馈列表" style="width:1100px;height:400px" class="easyui-datagrid">
    </table>
    <div id="feedbackToolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroy()">删除</a>
    </div>
    
    <script type="text/javascript">
    $(function () {
	    //加载信息
	    $('#feedbackDg').datagrid({
	    	idField:"id",
	        url: 'feedback_getData.action',
	        loadMsg: '数据装载中......',
	        singleSelect: true,
	        columns: [[
	        { field: 'id', title: '编号', width: 100 },
	        { field: 'feedbackContent', title: '反馈内容', width: 100 },
	        { field: 'insertTime', title: '插入时间', width: 100 },
	        { field: 'user', title: '用户', width: 100, 
	        	formatter: function(value,row,index){
	        		return row.user.userAccount;
	        	} 
	        },
	        { field: 'feedbackStatus', title: '状态', width: 100,
	        	formatter: function(value,row,index){
	        		switch (row.feedbackStatus) {
					case 0:
						return "未处理";
						break;
					case 1:
						return "已处理";
						break;
					default:
						break;
					}
	        	} 
	        },
	        { field: '', title: '操作', width: 100, 
	        	formatter: function(value,row,index){
	        		switch (row.feedbackStatus) {
					case 0:
						return '<a href="#" onclick="deal()">处理</a>';
						break;
					default:
						return "无";
						break;
					}
	        	} 
	        }
	        ]],
	        pagination: true,
	        toolbar:'#feedbackToolbar',
	        fitColumns:true,
	        rownumbers: true
	    });
	});
    
    var url;
    function destroy(){
        var row = $('#feedbackDg').datagrid('getSelected');
        if (row){
            $.messager.confirm('提示','你确定要删除这条记录？',function(r){
                if (r){
                    $.post('feedback_delete.action',{id:row.id},function(result){
                        if (result.errorMsg){
                        	$.messager.show({    // show error message
                                title: 'Error',
                                msg: result.errorMsg
                            });
                        } else {
                        	$('#feedbackDg').datagrid('reload');    // reload the user data
                        }
                    },'json');
                }
            });
        }
    }
    
    function deal(){
        var row = $('#feedbackDg').datagrid('getSelected');
        if (row){
            $.messager.confirm('提示','你确定已经处理该投诉？',function(r){
                if (r){
                    $.post('feedback_deal.action',{id:row.id},function(result){
                        if (result.errorMsg){
                        	$.messager.show({    // show error message
                                title: 'Error',
                                msg: result.errorMsg
                            });
                        } else {
                        	$('#feedbackDg').datagrid('reload');    // reload the user data
                        }
                    },'json');
                }
            });
        }
    }
</script>
</body>
</html>